package com.ctgu.蓝桥杯真题.B组2019;

import sun.net.util.IPAddressUtil;

import java.io.*;
import java.util.Arrays;

/**
 * @author: Backdiy
 * @data: 2021/4/8 21:11
 * @desc:
 */
public class C数列求值 {
    public static void main(String[] args) {
        long f[] = new long[]{1, 1, 1};
        for (int i = 3; i < 20190324; i++) {
            f[i % 3] = (f[(i - 3) % 3] + f[(i - 2) % 3] + f[(i - 1) % 3]) % 10000;
        }
        Input.out.println(f[(20190324-1)%3]);
        Input.out.flush();
    }

    static class Input {
        static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));
        static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        static int nextInt() throws IOException {
            streamTokenizer.nextToken();
            return (int) streamTokenizer.nval;
        }

        static double nextDouble() throws IOException {
            streamTokenizer.nextToken();
            return streamTokenizer.nval;
        }

        static long nextLong() throws IOException {
            streamTokenizer.nextToken();
            return (long) streamTokenizer.nval;
        }

        static String nextLine() throws IOException {
            return bufferedReader.readLine();
        }

        static char next() throws IOException {
            return (char) bufferedReader.read();
        }
    }
}
